package iot.wlink.network.protocols.mqtt;

import lombok.extern.slf4j.Slf4j;
import net.dreamlu.iot.mqtt.core.server.event.IMqttConnectStatusListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author : willian fu
 * @date : 2021/8/21
 */
@Slf4j
@Component
public class MqttConnectStatusListener implements IMqttConnectStatusListener {
    @Autowired
    private MqttDeviceManager deviceManager;

    @Override
    public void online(String uid) {
        deviceManager.deviceOnline(uid);
        log.info("MQTT设备[{}]上线", uid);
    }

    @Override
    public void offline(String uid) {
        deviceManager.deviceOffline(uid);
        log.warn("MQTT设备[{}]下线", uid);
    }
}
